var prefix = "/analyze/client";
$(function() {
    loadwdDate();


});

function load() {
    var timeYear= $('#timeYear').val();
    $("#spanval").text(timeYear);

    //var id = GetQueryString("id");
    var id=$("#chartid").val();

    $.ajax({
        url:prefix+"/clientfluctuatechart",
        dataType:"json",
        data:{id:id,timeYear:timeYear},
        type:"get",
        success:function (result) {
            // 基于准备好的dom，初始化echarts实例
            var myChart = echarts.init(document.getElementById('echarts-line-chart'));


                // 指定图表的配置项和数据

            var option = {
                title: {
                    text: '销量'
                },
                tooltip: {},
                legend: {
                    data:['销量',"金额"]
                },
                xAxis: {
                    data: result.businessDayList
                },
                yAxis: {},
                series: [{
                    name: '销量',
                    type: 'bar',
                    data: result.countWDList
                },{
                    name: '金额',
                    type: 'bar',
                    data: result.pricesWDList
                }]
            };

                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);

        },
        error:function () {
            alert("系统访问失败！")
        }
    })


}

function loadwdDate() {
    var now = new Date();
    var year = now.getFullYear(); //得到年份
    var y = "<option value='"+year+"' select>"+year+"</option>";
    for (var i=year-1;i>=(year-8);i--){

        y+="<option value='"+i+"'>"+i+"</option>"
    }
    $('#timeYear').append(y);


    load();

}

